home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / SETUP / US / CBUILDER / DATA.Z / MAPIWIN.H < prev    next >
C/C++ Source or Header  |  1997-02-13  |  16KB  |  449 lines

  1. /*
  2.  *  M A P I W I N . H
  3.  *
  4.  *  Definitions used by the MAPI Development Team to aid in
  5.  *  developing single-source service providers that run on
  6.  *  both WIN32 and WIN16 platforms.
  7.  *  There are three sections.
  8.  *
  9.  *  The first section defines how to call something that
  10.  *  is available by different methods in WIN16 vs. WIN32.
  11.  *  As such, they are totally new mechanisms.
  12.  *
  13.  *  The second section establishes things that are available
  14.  *  AS-IS in one environment but we have to define for the
  15.  *  other environment.
  16.  *
  17.  *  The third section simply defines a few conventions
  18.  *  (simplifications) for common operations.
  19.  *
  20.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  21.  */
  22.  
  23. /*
  24.  *  Routines are included in the first section to manage per-instance
  25.  *  global variables for DLLs. They assume that all of the DLL's
  26.  *  per-instance global variables live in a single block of memory.
  27.  *  Functions are provided to install and retrieve the correct block of
  28.  *  memory for the current instance.
  29.  *
  30.  *  There are only two functions:
  31.  *
  32.  *      PvGetInstanceGlobals    Call this to get the address of the
  33.  *                              per-instance globals structure.
  34.  *      ScSetinstanceGlobals    Call this to install the
  35.  *                              per-instance globals structure. It
  36.  *                              may fail if the number of instances
  37.  *                              exceeds a certain limit.
  38.  *
  39.  *  The caller is free to choose the name, size, and allocation
  40.  *  method of the per-instance global variables structure.
  41.  *
  42.  *  The WIN32 implementation uses a pointer in the DLL's data
  43.  *  segment. This assumes that the DLL gets a separate instance
  44.  *  of the default data segment per calling process.
  45.  *
  46.  *  The WIN16 implementation uses a fixed array of pointers and a
  47.  *  matching fixed array of keys unique to the calling process.
  48.  */
  49.  
  50. /*
  51.  *  The second section consists largely of Win32 file I/O functions
  52.  *  that are not supported under Win16. These functions are
  53.  *  implemented in mapiwin.c, using DOS calls. Most have limitations
  54.  *  relative to their Win32 counterparts, which are spelled out in
  55.  *  the comments to the source code.
  56.  */
  57.  
  58. #ifndef __MAPIWIN_H__
  59. #define __MAPIWIN_H__
  60. #pragma option -b
  61.  
  62. #ifdef __BORLANDC__
  63. #pragma option -b.
  64.   #include <pshpack8.h>
  65. #pragma option -b
  66. #endif
  67.  
  68. #if defined (WIN32) && !defined (_WIN32)
  69. #define _WIN32
  70. #endif
  71.  
  72. #pragma option -b.
  73. #include "mapinls.h"
  74. #pragma option -b
  75.  
  76. #ifdef __cplusplus
  77. extern "C" {
  78. #endif
  79.  
  80.  
  81. /********************************/
  82. /*  Our conventions for things  */
  83. /*  we choose to do differently */
  84. /*  on WIN16 vs. WIN32.         */
  85. /********************************/
  86.  
  87. #ifdef  WIN16
  88.  
  89. #define MULDIV(x,y,z)               MulDiv32(x,y,z)
  90. #define IsBadReadPtr(lp,cb)         FBadReadPtr(lp,cb)
  91.  
  92. #define cInstMax                    50
  93. LPVOID FAR PASCAL   PvGetInstanceGlobals(void);
  94. LONG FAR PASCAL     ScSetInstanceGlobals(LPVOID pv);
  95. LONG FAR PASCAL     ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid);
  96. LPVOID FAR PASCAL   PvGetVerifyInstanceGlobals(DWORD dwPid);
  97. LPVOID FAR PASCAL   PvSlowGetInstanceGlobals(DWORD dwPid);
  98. BOOL __export FAR PASCAL FCleanupInstanceGlobals(WORD, DWORD);
  99.  
  100. #elif defined(_MAC) /* !WIN16 */
  101.  
  102. #define MULDIV(x,y,z)               MulDiv(x,y,z)
  103.  
  104. LPVOID FAR PASCAL   PvGetInstanceGlobals(WORD wDataSet);
  105. LONG FAR PASCAL     ScSetInstanceGlobals(LPVOID pv, WORD wDataSet);
  106. LONG FAR PASCAL     ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid,
  107.                         WORD wDataSet);
  108. LPVOID FAR PASCAL   PvGetVerifyInstanceGlobals(DWORD dwPid, DWORD wDataSet);
  109. LPVOID FAR PASCAL   PvSlowGetInstanceGlobals(DWORD dwPid, DWORD wDataSet);
  110. BOOL FAR PASCAL     FCleanupInstanceGlobals(WORD, DWORD);
  111.  
  112. #else   /* !WIN16 */
  113.  
  114. #define MULDIV(x,y,z)               MulDiv(x,y,z)
  115.  
  116. extern LPVOID pinstX;
  117. #define PvGetInstanceGlobals()                  pinstX
  118. #define ScSetInstanceGlobals(_pv)               (pinstX = _pv, 0)
  119. #define PvGetVerifyInstanceGlobals(_pid)        pinstX
  120. #define ScSetVerifyInstanceGlobals(_pv,_pid)    (pinstX = _pv, 0)
  121. #define PvSlowGetInstanceGlobals(_pid)          pinstX
  122.  
  123. #endif  /* WIN16 */
  124.  
  125. #if defined(_WIN32) && !defined(_MAC)
  126. #define szMAPIDLLSuffix     "32"
  127. #elif defined(WIN16) || defined(DOS)
  128. #define szMAPIDLLSuffix     ""
  129. #elif  defined(_MAC)
  130. #define szMAPIDLLSuffix     "M"
  131. #else
  132. #error "Don't know the suffix for DLLs on this platform"
  133. #endif
  134.  
  135. /********************************/
  136. /*  Things missing from one     */
  137. /*  system-provided environment */
  138. /*  or the other.               */
  139. /********************************/
  140.  
  141. #if !defined(_WIN32) 
  142. #define ZeroMemory(pb,cb)           memset((pb),0,(cb))
  143. #define FillMemory(pb,cb,b)         memset((pb),(b),(cb))
  144. #define CopyMemory(pbDst,pbSrc,cb)  do                              \
  145.                                     {                               \
  146.                                         size_t _cb = (size_t)(cb);  \
  147.                                         if (_cb)                    \
  148.                                             memcpy(pbDst,pbSrc,_cb);\
  149.                                     } while (FALSE)
  150. #define MoveMemory(pbDst,pbSrc,cb)  memmove((pbDst),(pbSrc),(cb))
  151.  
  152. #define UNALIGNED
  153.  
  154. #endif
  155.  
  156. #if defined(WIN16) || defined(_MAC)
  157.  
  158. #ifndef _MAC
  159. #pragma option -b.
  160. #include <error.h>              /*  for GetLastError() */
  161. #pragma option -b
  162. #endif
  163.  
  164. typedef int                 INT;
  165. typedef unsigned long       ULONG;
  166. typedef short               SHORT;
  167. typedef unsigned short      USHORT;
  168. typedef double              LONGLONG;
  169. typedef double              DWORDLONG;
  170. typedef unsigned char       UCHAR;
  171. typedef unsigned char FAR*  PUCHAR;
  172. typedef int                 BOOL;
  173.  
  174.  
  175. #ifndef _MAC
  176. typedef char                BOOLEAN;
  177.  
  178. #ifndef _FILETIME_
  179. #define _FILETIME_
  180. typedef struct tagFILETIME
  181. {
  182.     DWORD dwLowDateTime;
  183.     DWORD dwHighDateTime;
  184. } FILETIME;
  185. #endif      /* _FILETIME */
  186.  
  187. typedef struct _SYSTEMTIME {
  188.     WORD wYear;
  189.     WORD wMonth;
  190.     WORD wDayOfWeek;
  191.     WORD wDay;
  192.     WORD wHour;
  193.     WORD wMinute;
  194.     WORD wSecond;
  195.     WORD wMilliseconds;
  196. } SYSTEMTIME, *PSYSTEMTIME, FAR *LPSYSTEMTIME;
  197.  
  198. typedef struct _TIME_ZONE_INFORMATION {
  199.     LONG Bias;
  200.     CHAR StandardName[ 32 ];        /* was WCHAR */
  201.     SYSTEMTIME StandardDate;
  202.     LONG StandardBias;
  203.     CHAR DaylightName[ 32 ];        /* was WCHAR */
  204.     SYSTEMTIME DaylightDate;
  205.     LONG DaylightBias;
  206. } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, FAR *LPTIME_ZONE_INFORMATION;
  207.  
  208.  
  209. #if defined(DOS) || defined(WIN16)
  210. /* Simulate effect of afx header */
  211. #define __T(x)      x
  212. #define _T(x)       __T(x)
  213. #define TEXT        _T
  214. #endif
  215.  
  216. #define APIENTRY        WINAPI
  217.  
  218. #define SetForegroundWindow         SetActiveWindow
  219.  
  220. #define wsprintfA                   wsprintf
  221. #define GetWindowsDirectoryA        GetWindowsDirectory
  222. #define GetSystemDirectoryA         GetSystemDirectory
  223. #define GetPrivateProfileStringA    GetPrivateProfileString
  224. #define GetPrivateProfileIntA       GetPrivateProfileInt
  225. #define GetProfileStringA           GetProfileString
  226. #define GetModuleFileNameA          GetModuleFileName
  227. #define CharUpperBuffA              CharUpperBuff
  228. #define LoadLibraryA                LoadLibrary
  229. #define lstrcatA                    lstrcat
  230. #define RegisterWindowMessageA      RegisterWindowMessage
  231. #define MAKEINTRESOURCEA            MAKEINTRESOURCE
  232.  
  233. #define WNDCLASSA                   WNDCLASS                                    
  234.  
  235. #endif  /* !_MAC */
  236.  
  237. /* Synchronization */
  238. #define InterlockedIncrement(plong) (++(*(plong)))
  239. #define InterlockedDecrement(plong) (--(*(plong)))
  240.  
  241. #ifndef CreateMutex
  242. #define CreateMutexA    CreateMutex
  243. #define CreateMutexW    CreateMutex
  244. #define CreateMutex(pv, bool, sz)   (INVALID_HANDLE_VALUE)
  245. #endif
  246.  
  247. #define WaitForSingleObject(hObj, dw)   ((void)0)
  248. #define ReleaseMutex(hObj)              ((BOOL)1)
  249. #define CloseMutexHandle(hObj)          TRUE
  250.  
  251. #define CRITICAL_SECTION            ULONG
  252. #define InitializeCriti